﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////


#pragma once
#include "GmUiModelFamily.h"
#include "IDocumentEventHandler.h"

namespace gcmp
{
    struct Any;
}

namespace gfam
{
    class GM_UI_MODEL_FAMILY_EXPORT ArchitectureDynamicPanelParameterManager :public gcmp::IDocumentEventHandler
    {
    public:
        typedef std::wstring ParameterId;
        virtual ~ArchitectureDynamicPanelParameterManager();

        static ArchitectureDynamicPanelParameterManager* GetInstance();
        bool AddValue(const std::wstring& cmdId, const std::wstring& paramName, const gcmp::Any& value);
        bool RemoveValue(const std::wstring& cmdId, const std::wstring& paramName);
        bool GetValue(const std::wstring& cmdId, const std::wstring& paramName, gcmp::Any& value);
        bool UpdateValue(const std::wstring& cmdId, const std::wstring& paramName, const gcmp::Any& value);

        virtual void On(gcmp::IDocumentEventArgs* pArgs) override;

    private:
        ArchitectureDynamicPanelParameterManager();

        std::wstring GetParameterId(const std::wstring& cmdId, const std::wstring& paramName);
        void Reset();
    private:
        std::map<ParameterId, gcmp::Any> m_dynamicPanelParameterValues;
        bool m_bListenedToDocEvent;

        static gcmp::OwnerPtr<ArchitectureDynamicPanelParameterManager> m_dynamicPanelParameterManager;
    };
}
